package com.huawei.appgallery.foundation.ui.framework.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.MotionEvent;
import androidx.viewpager.widget.ViewPager;
import o.cjy;
import o.cjy.d;
import o.dky.o;
import o.Logger;

public class BounceViewPager extends FixViewPager implements d {
    private static final String ˊ = BounceViewPager.class.getSimpleName();
    private boolean ʻ = false;
    private int ʼ = 2;
    private cjy ʽ = null;
    protected boolean ˋ = false;
    private int ॱॱ;
    private int ᐝ = 0;

    public BounceViewPager(Context context) {
        super(context);
        ˋ(null);
    }

    public BounceViewPager(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        ˋ(attributeSet);
    }

    private void ˋ(AttributeSet attributeSet) {
        if (attributeSet != null) {
            TypedArray typedArray = null;
            try {
                typedArray = getContext().obtainStyledAttributes(attributeSet, o.ʻʽ);
                this.ˋ = typedArray.getBoolean(o.ʻʻ, false);
                if (typedArray != null) {
                    typedArray.recycle();
                }
            } catch (Exception e) {
                Logger.e(ˊ, "init(AttributeSet attrs) " + e.toString());
                if (typedArray != null) {
                    typedArray.recycle();
                }
            } catch (Throwable th) {
                if (typedArray != null) {
                    typedArray.recycle();
                }
            }
        }
        if (this.ˋ) {
            this.ʽ = new cjy((ViewPager) this);
        }
    }

    public void setPageCount(int i) {
        this.ʼ = i;
    }

    public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        boolean z;
        if (this.ᐝ <= 2 && 1 == motionEvent.getAction()) {
            this.ᐝ++;
        }
        if (this.ᐝ > 2) {
            z = true;
        } else {
            z = false;
        }
        z = z && this.ˋ;
        this.ʻ = z;
        if (this.ʻ && this.ʽ != null && this.ʽ.ˋ(motionEvent)) {
            try {
                super.onInterceptTouchEvent(motionEvent);
                return true;
            } catch (IllegalArgumentException e) {
                Logger.ˋ(ˊ, "onInterceptTouchEvent  IllegalArgumentException:" + e.toString());
                return true;
            }
        }
        try {
            return super.onInterceptTouchEvent(motionEvent);
        } catch (IllegalArgumentException e2) {
            return false;
        }
    }

    public boolean onTouchEvent(MotionEvent motionEvent) {
        boolean z;
        if (this.ᐝ <= 2 && 1 == motionEvent.getAction()) {
            this.ᐝ++;
        }
        if (this.ᐝ > 2) {
            z = true;
        } else {
            z = false;
        }
        z = z && this.ˋ;
        this.ʻ = z;
        try {
            if (this.ʻ && this.ʽ != null && this.ʽ.ˏ(motionEvent)) {
                return true;
            }
            return super.onTouchEvent(motionEvent);
        } catch (IllegalArgumentException e) {
            Logger.e(ˊ, "onTouchEvent(MotionEvent ev) " + e.toString());
            return false;
        }
    }

    public void ˎ(int i, float f, int i2) {
        this.ॱॱ = i2;
        super.ˎ(i, f, i2);
    }

    public boolean ˌ() {
        return getCurrentItem() == 0 && this.ॱॱ == 0;
    }

    public boolean ˋˋ() {
        return getCurrentItem() == this.ʼ + -1 && this.ॱॱ == 0;
    }

    public boolean ˎˎ() {
        return false;
    }

    public boolean ˋᐝ() {
        return false;
    }

    public void setBounceEnable(boolean z) {
        this.ˋ = z;
    }
}
